// Package routers 包含相关的路由配置
// @author 5title_
// @date 2025-04-01

package business

import (
	"5title_gin/internal/api/middleware"
	"5title_gin/internal/api/v1/business"
	"5title_gin/internal/model"
	"5title_gin/internal/model/business/orders"

	"github.com/gin-gonic/gin"
)

// OrdersRouter 注册路由
func OrdersRouter(privateAPI *gin.RouterGroup, publicAPI *gin.RouterGroup) {
	// 获取API实例
	app := business.NewOrdersAPI()

	// 需要认证的API
	ordersAPI := privateAPI.Group("/business/orders")
	{
		// 获取列表
		ordersAPI.GET("", middleware.BindQueryMiddleware[model.PageInfo], app.GetOrdersList)
		// 获取单个
		ordersAPI.GET("/:id", app.GetOrders)
		// 创建
		ordersAPI.POST("", middleware.BindJsonMiddleware[orders.Orders], app.CreateOrders)
		// 更新
		ordersAPI.PUT("/:id", middleware.BindJsonMiddleware[orders.Orders], app.UpdateOrders)
		// 删除
		ordersAPI.DELETE("/:id", app.DeleteOrders)
	}
}
